#include "fx_compressor.h"
#include "ui_fx_compressor.h"

fx_compressor::fx_compressor(QWidget *parent) :
    fx_basic(parent),
    ui(new Ui::fx_compressor)
{
    ui->setupUi(this);

    ui->label_gain->setText(QString::number(0) + " dB");
    ui->label_attack->setText(QString::number(10) + " ms");
    ui->label_release->setText(QString::number(200) + " ms");
    ui->label_thres->setText(QString::number(-20) + " dB");
    ui->label_ratio->setText(QString::number(3));
    ui->label_pred->setText(QString::number(4) + " ms");
}

fx_compressor::~fx_compressor()
{
    delete ui;
}

void fx_compressor::gain(int value)
{
    ui->label_gain->setText(QString::number(value) + " dB");
}

void fx_compressor::attack(int value)
{
    ui->label_attack->setText(QString::number(double(value)/ 100) + " ms");
}

void fx_compressor::release(int value)
{
    ui->label_release->setText(QString::number(value) + " ms");
}

void fx_compressor::thres(int value)
{
    ui->label_thres->setText(QString::number(value) + " dB");
}

void fx_compressor::ratio(int value)
{
    ui->label_ratio->setText(QString::number(value));
}

void fx_compressor::predelay(int value)
{
    ui->label_pred->setText(QString::number(value) + " ms");
}

void fx_compressor::addFX()
{
    BASS_DX8_COMPRESSOR* result = new BASS_DX8_COMPRESSOR();
    result->fGain = ui->slide_gain->value();//0.0;
    result->fAttack = float(ui->slide_attack->value()) / 100;
    result->fRelease = ui->slide_release->value();
    result->fThreshold = ui->slide__thres->value();
    result->fRatio = ui->slide_ratio->value();
    result->fPredelay = ui->slide_predelay->value();
    emit apply(BASS_FX_DX8_COMPRESSOR, result);
}
